package com.xmmj.baselibrary.utils.viewadapter.wheelview

import androidx.databinding.BindingAdapter
import com.xmmj.baselibrary.widget.wheelview.ArrayWheelAdapter
import com.xmmj.baselibrary.widget.wheelview.OnWheelChangedListener
import com.xmmj.baselibrary.widget.wheelview.WheelView

@BindingAdapter(value = ["items", "visibleItems", "cyclic", "position"], requireAll = false)
fun setParams(
    wheelView: WheelView,
    item: ArrayList<String>,
    visibleItems: Int,
    cyclic: Boolean,
    position: Int
) {
    wheelView.setAdapter(ArrayWheelAdapter(item))
    wheelView.setVisibleItems(visibleItems)
    wheelView.setCyclic(cyclic)
    wheelView.setCurrentItem(position)
}

@BindingAdapter(value = ["onWheelChangedListener"], requireAll = false)
fun addChangingListener(wheelView: WheelView, onWheelChangedListener: OnWheelChangedListener) {
    onWheelChangedListener.let {
        wheelView.addChangingListener(it)
    }
}

